package com.bwie.controller;

import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbOrderService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/6/26 15:09
 * @Version 1.0
 */
@RestController
@RequestMapping("/shop/order")
public class OrderController {

    @Autowired
    TbOrderService tbOrderService;

    /**
     * 订单分页列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getOrderList")
    public R getOrderList(@RequestBody PageInfoVo pageInfoVo){
        return tbOrderService.getOrderList(pageInfoVo);
    }

    /**
     * 添加订单
     * @param infoList
     * @return
     */
    @PostMapping("/addOrder")
    public R addOrder(@RequestBody List<TbProdInfo> infoList){
        return tbOrderService.addOrder(infoList);
    }

    /**
     * 导出订单列表数据
     * @param userId
     */
    @GetMapping("/exportOrderList/{userId}")
    public void exportOrderList(@PathVariable("userId") Integer userId){
        tbOrderService.exportOrderList(userId);
    }

    /**
     * 批量删除订单
     * @param ids
     * @return
     */
    @PostMapping("/deleteBatchOrder")
    public R deleteBatchOrder(@RequestBody List<Integer> ids){
        return tbOrderService.deleteBatchOrder(ids);
    }

    @PostMapping("/getOrderInfoById/{orderId}")
    public R getOrderInfoById(@PathVariable("orderId") Integer orderId){
        return tbOrderService.getOrderInfoById(orderId);
    }
}
